fix(agent-core-v2): restore turn-start model fallback - #364
Merged
Merged
Conversation
commit: |
When the bound model no longer resolves at turn start, switch to the best-ranked ready model and emit ModelFallbackSwitched, a model-fallback warning, and model_fallback_triggered telemetry. #323 dropped this.
elkaix
force-pushed
the
fix/restore-turn-model-fallback
branch
from
October 2, 2026 23:36
74f8b0d to
2c7716d
Compare
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 23 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (9)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Merged
elkaix
pushed a commit
that referenced
this pull request
Oct 3, 2026
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @pymodel/pythinker-code@2.5.2 ### Patch Changes - [#364](#364) [`c431d50`](c431d50) Thanks [@elkaix](https://github.com/elkaix)! - A session whose model was deleted or lost its provider switches to the best available model at the next turn, with a warning, instead of failing the turn. - [#365](#365) [`81f1070`](81f1070) Thanks [@elkaix](https://github.com/elkaix)! - Clients that open a session while a tool approval is pending now show the agent's status instead of none. ## @pymodel/pythinker-desktop@1.6.2 ### Patch Changes - [#364](#364) [`c431d50`](c431d50) Thanks [@elkaix](https://github.com/elkaix)! - A session whose model was deleted or lost its provider switches to the best available model at the next turn, with a warning, instead of failing the turn. - [#365](#365) [`81f1070`](81f1070) Thanks [@elkaix](https://github.com/elkaix)! - Clients that open a session while a tool approval is pending now show the agent's status instead of none. Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
Resolve #351
Bug Reproduction Steps
Bind a session to a model, then delete that model (or its provider) from the config. The next turn fails with an unresolved-model error. Before #323 it switched to a ready model.
Root Cause
#323 (upstream reconcile) removed
ensureResolvableModelfromAgentProfileService.resolveModelContext, together with theModelFallbackSwitchedevent, themodel_fallback_triggeredtelemetry event, and the ranking policy. This PR restores them in the currentllm-adapterlayout. Fundamental fix.Code Changes
llm-adapter/model/default-model-policy.ts:rankDefaultModelCandidates, ported unchanged from the pre-chore: upstream reconcile through reference 99eaa993b #323kosong/model/defaultModelPolicy.ts.profileService.ts:resolveModelContext(turnId)runsensureResolvableModelat turn bind. If the bound alias does not resolve, it switches to the first ranked candidate that does resolve, then emitsModelFallbackSwitched, amodel-fallbackWarningIssued, andmodel_fallback_triggeredtelemetry. If no candidate resolves, nothing changes.llmRequesterService.ts: passesturnIdwhen it builds the per-turn config. This is the only caller that passes it. Compaction and credential lookups stay read-only.profileOps.tsandtelemetry/events.ts: event and telemetry definitions restored.test/agent/profile/modelFallback.test.tsports the five pre-chore: upstream reconcile through reference 99eaa993b #323 cases. Three of them fail without the fix. Two test DI setups getIModelServiceandIProviderServicestubs.Not restored: the global default-model fallback (
settleDefaultModel). As the issue comment says, #323 madedefault_modelnever be rewritten, so bringing that back is a product decision.Behavior Changes and Affected Users
/modelturn.model_fallback.switchedAffected module:
agent-core-v2profile. Full suites pass: agent-core-v2 6498/6498, agent-gateway 1407/1407.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.